﻿using System.IO;
using System.Text;
using Microsoft.Win32;

namespace EvoGame.Ceeforee.Core.Helpers
{
	public static partial class Helper
	{
		public static DirectoryInfo[] GetMods(CivX mode)
		{
			DirectoryInfo modDir = new DirectoryInfo(CivDir(mode)+"\\Mods");
			DirectoryInfo[] mods;
			try
			{
				 mods = modDir.GetDirectories();
			}
			catch (DirectoryNotFoundException dnf)
			{
				EvoGame.Core.Components.Application.Debug.Output = dnf.Message;
				EvoGame.Core.Components.Application.Debug.Output = "Civ Directory not found. Aborting...";
				System.Windows.Forms.Application.Exit();
				mods = null;
			}
			return mods;
		}

		public static string CivDir(CivX mode)
		{
			StringBuilder civDir = new StringBuilder();
			civDir.Append(Registry.LocalMachine.OpenSubKey("Software").OpenSubKey("Firaxis Games").OpenSubKey("Sid Meier\'s Civilization 4").GetValue("InstallDir", "C:\\Program Files\\Firaxis Games\\Sid Meier\'s Civilization 4").ToString());
			switch (mode)
			{
				default:
				case CivX.Vanilla:
					break;
				case CivX.Warlords:
					civDir.Append("\\Warlords");
					break;
				case CivX.BeyondTheSword:
					civDir.Append("\\Beyond the Sword");
					break;
			}
			return civDir.ToString();
		}
	}
}
